import { createPinia, defineStore } from 'pinia'
import { UserInfo } from '@typings/user'
import { Log } from '@utils/log'

export const useAppStore = defineStore('appStore', {
  state: () => ({
    userInfo: {} as UserInfo
  }),
  actions: {
    setUserInfo (value: UserInfo) {
      if (value.role) value.role = ''
      if (value.permission) value.permission = new Set<string>()
      this.userInfo = value
      Log.userInfo = value
    }
  }
})

export default createPinia()
